
package com.enlorenz.core.channel.socket.common.reader;

import java.io.InputStream;

import com.enlorenz.common.util.CodeUtils;

/**
 * 带长度的格式的报文读取类器
 * @author lcb
 */
public class LengthBodySocketReader extends AbstractLengthBodyReader implements ISocketReader{
	private InputStream inputStream;

	@Override
	protected byte[] readLength(int length) throws Exception {
		byte[] buff = new byte[length];
		int readed = inputStream.read(buff, 0, buff.length);
		if(readed <=0){
			return null;
		}
		byte [] real=CodeUtils.substrBytes(buff, readed);
		return real;
	}

	public InputStream getInputStream() {
		return inputStream;
	}

	public void setInputStream(InputStream inputStream) {
		this.inputStream = inputStream;
	}

}
